// 路由配置信息
import Home from '@/pages/Home'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Search from '@/pages/Search'
import Detail from '@/pages/Detail'
import AddCartSuccess from '@/pages/AddCartSuccess'
import ShopCart from '@/pages/ShopCart'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import PaySuccess from '@/pages/PaySuccess'
import Center from '@/pages/Center'
// 二级路由
import MyOrder from '@/pages/Center/myOrder'
import GroupOrder from '@/pages/Center/groupOrder'
export default [
    {
        path:"/center",
        component:Center,
        meta:{show:true},
        children:[
            {
                path:'myorder',
                component:MyOrder
            },
            {
                path:'grouporder',
                component:GroupOrder
            },
            {
                path:'/center',
                redirect:'/center/myorder'
            }
        ]
    },
    {
        path:'/paysuccess',
        component:PaySuccess,
        meta:{show:true}
    },
    {
      path:'/pay',
      component:Pay,
      meta:{show:true} ,
    },
    {
        path:'/trade',
        component:Trade,
        meta:{show:true},
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            console.log(to.path);
            // 去交易页面，必须是从购物车而来
            if(from.path == '/shopcart'){
                next()
            }else{
                // 中断当前跳转
                next(false)
            }
        }
    },
    {
        path:'/shopcart',
        name:'shopcart',
        component:ShopCart
    },
    {
        path:'/home',
        component:()=>import ('@/pages/Home'),
        meta:{show:true}
    },
    {
        path:'/login',
        component:Login
    },
    {
        path:'/register',
        component:Register
    },
    {
        name:'search',
        path:'/search/:keyword?',
        component:Search,
        meta:{show:true}
    },
    {   
        name:'detail',
        path:'/detail/:skuId?',
        component:Detail,
        meta:{show:true}
    },
    {
        name:'addcartsuccess',
        path:'addcartsuccess',
        component: AddCartSuccess,
        meta:{show:true}
    },
    {
        path:'/',
        redirect:'/home'
    }
]